package com.yanqu.road.entity.rank.cross;

import com.yanqu.road.entity.DataObject;
import org.apache.mina.util.ConcurrentHashSet;

import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 游戏服确认上传排行的记录
 */

public class CrossMonthRankUploadOver extends DataObject {
    private int month;
    private Set<Long> serverIds = new ConcurrentHashSet<>();
    /**
     * 活跃人数 K:groupId
     */
    private Map<Integer, Integer> rankNumMap = new ConcurrentHashMap<>();
    /**
     * 评定时间 K:groupId
     */
    private Map<Integer, Long> rankTimeMap = new ConcurrentHashMap<>();

    public int getMonth() {
        return month;
    }

    public void setMonth(int month) {
        if (this.month != month) {
            this.month = month;
            setUpdateOption();
        }
    }

    public Set<Long> getServerIds() {
        return serverIds;
    }

    public void setServerIds(Set<Long> serverIds) {
        this.serverIds = serverIds;
    }

    public void addServerId(long serverId) {
        if (!this.serverIds.contains(serverId)) {
            this.serverIds.add(serverId);
            setUpdateOption();
        }
    }

    public int getRankNum(int groupId) {
        return rankNumMap.getOrDefault(groupId, 0);
    }

    public void setRankNum(int groupId, int rankNum) {
        rankNumMap.put(groupId, rankNum);
        setUpdateOption();
    }

    public Map<Integer, Integer> getRankNumMap() {
        return rankNumMap;
    }

    public void setRankNumMap(ConcurrentHashMap<Integer, Integer> rankNumMap) {
        this.rankNumMap = rankNumMap;
    }

    public Map<Integer, Long> getRankTimeMap() {
        return rankTimeMap;
    }

    public void setRankTimeMap(Map<Integer, Long> rankTimeMap) {
        this.rankTimeMap = rankTimeMap;
    }

    public void setRankTime(int groupId, long time) {
        this.rankTimeMap.put(groupId, time);
        setUpdateOption();
    }

    public long getRankTime(int groupId) {
        return this.rankTimeMap.getOrDefault(groupId, 0l);
    }
}
